package com.hsjk.szwj.module.train.enums;

import cn.hutool.core.util.ArrayUtil;
import com.hsjk.szwj.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/28 11:37
 **/
@AllArgsConstructor
@Getter
public enum OrderCancelTypeEnum implements IntArrayValuable {
    UN_CANCEL(1, "未取消"),
    MEMBER(2, "用户取消"),
    SYSTEM(3, "系统取消");
    public static final int[] ARRAYS = Arrays.stream(values())
            .mapToInt(OrderCancelTypeEnum::getValue).toArray();

    /**
     * 类型
     */
    private final Integer value;
    /**
     * 类型名
     */
    private final String name;

    public static OrderCancelTypeEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), OrderCancelTypeEnum.values());
    }

    @Override
    public int[] array() {
        return ARRAYS;
    }
}
